#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

#define SIZE 4 * 1024 * 1024

unsigned int buffer[SIZE];
int main(int argc, char *argv[])
{
    int bytes_in, i, end;
    while ((bytes_in = read(0, buffer, sizeof(buffer))) > 0) {
        i = 0;
        end = bytes_in / sizeof(unsigned int);
        while(i < end) {
            buffer[i] = ((buffer[i] << 8) & 0xFF00FF00) | ((buffer[i] >> 8) & 0x00FF00FF); i++;
            buffer[i] = ((buffer[i] << 8) & 0xFF00FF00) | ((buffer[i] >> 8) & 0x00FF00FF); i++;
            buffer[i] = ((buffer[i] << 8) & 0xFF00FF00) | ((buffer[i] >> 8) & 0x00FF00FF); i++;
            buffer[i] = ((buffer[i] << 8) & 0xFF00FF00) | ((buffer[i] >> 8) & 0x00FF00FF); i++;
        }
        write(1, buffer, bytes_in);
    }
}

// Original ///////////////////////////////////////////////////////////////////

// void panic(char *miss)
// {
//         if (errno != 0)
//             perror(miss);
//         else
//             fprintf(stderr, "%s\n", miss);
//         exit(1);
// }

// int main(int argc, char *argv[])
// {
//     char c1, c2;
//     int n1, n2;
//     while (((n1=read(0, &c1, 1)) > 0) && ((n2=read(0, &c2, 1)) > 0))
//     {
//         if (write(1, &c2, 1) < 0) panic("write1");
//         if (write(1, &c1, 1) < 0) panic("write2");
//     }
//     if ((n1==-1) || (n2==-1)) panic("read");
//     if ((n1==1) && (n2==0))
//             if (write(1, &c1, 1) < 0) panic("write");
//     return 0;
// }
